// pages/user/user.js
var app = getApp()

Page({

  /**
   * 页面的初始数据
   */
  data: {
    show: false,
    identity: false
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {
    this.initUserInfo()
  },

  /**
   * initUserInfo
   */
  initUserInfo: function() {
    let that = this
    wx.showLoading({
      mask: true,
      title: app.globalData.loadText,
    })
    app.getAccessToken(app.getPageUrl(getCurrentPages())).then(function(accessToken) {
      wx.request({
        url: app.globalData.hostAPI + '/api/v1/user/index?access_token=' + accessToken,
        success: res => {
          if (res.data.status === 1) {
            if (res.data.data.rgl_cmdr.status == 20) {
              that.setData({
                identity: true,
              })
            } else {
              that.setData({
                identity: false,
              })
            }
          }
          wx.hideLoading()
        }
      })
    })
  },

  /**
   * 
   */
  showPickNum: function() {
    this.setData({
      show: true
    })
  },

  closePickNum: function() {
    this.setData({
      show: false
    })
  }
})